#########################################################################
##
## This file is part of the SAMRAI distribution.  For full copyright 
## information, see COPYRIGHT and LICENSE. 
##
## Copyright:     (c) 1997-2019 Lawrence Livermore National Security, LLC
## Description:   makefile for testing parts of SAMRAI library 
##
#########################################################################

SAMRAI        = @top_srcdir@
SRCDIR        = @srcdir@
OBJECT        = ../..
REPORT        = $(OBJECT)/report.xml
SUBDIR        = source/test

SUBDIRS = \
   testlib \
   logger \
   dimension \
   dataaccess \
   inputdb \
   restartdb \
   timers \
   variables \
   indexdata \
   sparsedata \
   transformation \
   samrai_mpi \
   async_comm \
   mapped_box_set_iterators \
   hierarchy \
   Connector \
   assumed_partition \
   OverlapConnectorAlgorithm \
   MappingConnector \
   mblktree \
   MappedBoxLevelConnectorUtilsTests \
   clustering \
   LoadBalanceCorrectness \
   dlbg \
   communication \
   patchbdrysum \
   dataops \
   hypre \
   FAC_staticrefinement \
   FAC_adaptive \
   vector \
   sundials \
   boundary \
   performance \
   mblkcomm \
   MblkEuler \
   MblkLinAdv \
   nonlinear \
   rank_group \
   fill_pattern \
   applications 

default: check 

include $(OBJECT)/config/Makefile.config

library:

check:
	$(RM) $(REPORT)
	touch $(REPORT)
	@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >> $(REPORT)
	@echo "<testsuites>" >> $(REPORT)
	@echo "  <testsuite name=\"smoke\">" >> $(REPORT)
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done
	@echo "  </testsuite>" >> $(REPORT)
	@echo "</testsuites>" >> $(REPORT)

check2d:
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done

check3d:
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done

checkcompile:
	@echo "Starting " $@ " in source/test at `date`"
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@) || exit 1; done
	@echo "Completed " $@ " in source/test at `date`"

checktest:
	$(RM) $(REPORT)
	touch $(REPORT)
	@echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" >> $(REPORT)
	@echo "<testsuites>" >> $(REPORT)
	@echo "  <testsuite name=\"smoke\">" >> $(REPORT)
	@echo "Starting " $@ " in source/test at `date`"
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done
	@echo "Completed " $@ " in source/test at `date`"
	@echo "  </testsuite>" >> $(REPORT)
	@echo "</testsuites>" >> $(REPORT)

examples:
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done

perf:
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done

everything:
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) checkcompile) || exit 1; done
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) checktest); done
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) examples); done
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) perf); done

clean:
	$(RM) $(REPORT)
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done

checkclean:
	$(RM) $(REPORT)
	for DIR in $(SUBDIRS); do (cd $$DIR && $(MAKE) $@); done
